class Dog(object):
    @staticmethod
    def work():
        print('dog is working')


class PoliceDog(Dog):
    @staticmethod
    def work():
        print('police dog is attacking enemy')


class GuideDog(Dog):
    @staticmethod
    def work():
        print('guide dog is guiding')


class DrugDetectionDog(Dog):
    @staticmethod
    def work():
        print('drug detection dog is working')


class Person(object):
    def __init__(self, name):
        self.name = name

    def work_with_dog(self):
        if self.dog is not None and isinstance(self.dog, Dog):
            self.dog.work()


p = Person('tom')
pd = PoliceDog()
gd = GuideDog()
ddd = DrugDetectionDog()
p.dog = pd
p.work_with_dog()
p.dog = gd
p.work_with_dog()
p.dog = ddd
p.work_with_dog()
p.dog = Dog()
p.work_with_dog()
